]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Don't add a new workspace when the maximum workspaces limit is reached
authorMarina Zhurakhinskaya <marinaz@redhat.com>
Thu, 13 May 2010 18:29:00 +0000 (14:29 -0400)
committerMarina Zhurakhinskaya <marinaz@redhat.com>
Thu, 13 May 2010 18:30:52 +0000 (14:30 -0400)
It was previously possible to add a workspace above the maximum workspaces
limit by dragging an item to the "add workspace" button or using the middle
mouse button click.

Provide the user with feedback in the info bar when it is not possible to create
a new workspace or remove the current workspace.

https://bugzilla.gnome.org/show_bug.cgi?id=591645

js/ui/appDisplay.js
js/ui/workspacesView.js
po/POTFILES.in

index 29aeaa89111e380eeaa66d634ec946b7ee4847ba..acc12fcd84a7b1f0177252ddae13ff7ba8ebd8db 100644 (file)
@@ -459,10 +459,12 @@ AppWellIcon.prototype = {
             this._onActivate(event);
         } else if (button == 2) {
             let newWorkspace = Main.overview.workspaces.addWorkspace();
-            newWorkspace.activate(global.get_current_time());
-            this.emit('launching');
-            this.app.open_new_window();
-            Main.overview.hide();
+            if (newWorkspace != null) {
+                newWorkspace.activate(global.get_current_time());
+                this.emit('launching');
+                this.app.open_new_window();
+                Main.overview.hide();
+            }
         } else if (button == 3) {
             // Don't bind to the right click here; we want left click outside the
             // area to deactivate as well.
index 8624cee0c5e58eca7c1a018366f64605e411ae37..7ba13b9fd1be5eb26096c9585106ad66d27a15c5 100644 (file)
@@ -11,6 +11,8 @@ const Pango = imports.gi.Pango;
 const Shell = imports.gi.Shell;
 const St = imports.gi.St;
 const Signals = imports.signals;
+const Gettext = imports.gettext.domain('gnome-shell');
+const _ = Gettext.gettext;
 
 const DND = imports.ui.dnd;
 const Lightbox = imports.ui.lightbox;
@@ -233,15 +235,31 @@ GenericWorkspacesView.prototype = {
     },
 
     addWorkspace: function() {
+        if (!this.canAddWorkspace()) {
+            Main.overview.infoBar.setMessage(_("Can't add a new workspace because maximum workspaces limit has been reached."));
+            return null;
+        }
+
+        return global.screen.append_new_workspace(false, global.get_current_time());
+    },
+
+    _getWorkspaceIndexToRemove: function() {
         throw new Error("Not implemented");
     },
 
     canRemoveWorkspace: function() {
-        throw new Error("Not implemented");
+        return this._getWorkspaceIndexToRemove() > 0;
     },
 
     removeWorkspace: function() {
-        throw new Error("Not implemented");
+        if (!this.canRemoveWorkspace()) {
+            Main.overview.infoBar.setMessage(_("Can't remove the first workspace."));
+            return;
+        }
+        let index = this._getWorkspaceIndexToRemove();
+        let metaWorkspace = this._workspaces[index].metaWorkspace;
+        global.screen.remove_workspace(metaWorkspace,
+                                       global.get_current_time());
     },
 
     updateWorkspaces: function() {
@@ -261,7 +279,9 @@ GenericWorkspacesView.prototype = {
     },
 
     _acceptNewWorkspaceDrop: function(source, dropActor, x, y, time) {
-        this.addWorkspace();
+        let ws = this.addWorkspace();
+        if (ws == null)
+            return false;
         return this.acceptNewWorkspaceDrop(source, dropActor, x, y, time);
     }
 };
@@ -444,19 +464,8 @@ MosaicView.prototype = {
         return null;
     },
 
-    addWorkspace: function() {
-        return global.screen.append_new_workspace(false, global.get_current_time());
-    },
-
-    canRemoveWorkspace: function() {
-        return global.screen.n_workspaces > 1;
-    },
-
-    removeWorkspace: function() {
-        let removedIndex = this._workspaces.length - 1;
-        let metaWorkspace = this._workspaces[removedIndex].metaWorkspace;
-        global.screen.remove_workspace(metaWorkspace,
-                                       global.get_current_time());
+    _getWorkspaceIndexToRemove: function() {
+        return this._workspaces.length - 1;
     }
 };
 
@@ -1377,10 +1386,6 @@ SingleView.prototype = {
         return actor;
     },
 
-    canRemoveWorkspace: function() {
-        return global.screen.get_active_workspace_index() != 0;
-    },
-
     _updatePanelVisibility: function() {
         let showSwitches = (global.screen.n_workspaces > 1);
         if (this._scroll != null) {
@@ -1392,17 +1397,15 @@ SingleView.prototype = {
     },
 
     addWorkspace: function() {
-        let ws = global.screen.append_new_workspace(false,
-                                                    global.get_current_time());
-        ws.activate(global.get_current_time());
+        let ws = GenericWorkspacesView.prototype.addWorkspace.call(this);
+        if (ws != null)
+            ws.activate(global.get_current_time());
+
         return ws;
     },
 
-    removeWorkspace: function() {
-        let removedIndex = global.screen.get_active_workspace_index();
-        let metaWorkspace = this._workspaces[removedIndex].metaWorkspace;
-        global.screen.remove_workspace(metaWorkspace,
-                                       global.get_current_time());
+    _getWorkspaceIndexToRemove: function() {
+        return global.screen.get_active_workspace_index();
     }
 };
 
@@ -1531,7 +1534,6 @@ WorkspacesControls.prototype = {
     _setButtonSensitivity: function(button, sensitive) {
         if (button == null)
             return;
-        button.reactive = sensitive;
         button.opacity = sensitive ? 255 : 85;
     },
 
index f770ea188e3a6e60d82d84a0301fb337fea2d15b..22936bc69d39b9749259f32aa5451f25b36f763d 100644 (file)
@@ -12,6 +12,7 @@ js/ui/placeDisplay.js
 js/ui/runDialog.js
 js/ui/statusMenu.js
 js/ui/windowAttentionHandler.js
+js/ui/workspacesView.js
 src/gdmuser/gdm-user.c
 src/shell-global.c
 src/shell-uri-util.c